
let num: number;
num = 123;
console.log(num);

let num1: number = 789;
console.log(num1);


let str1: string = 'abc';
let str2: string = 'efd';
let str3: string;
str3 = str1 + num1;
console.log(str1, str2, str3);


let bool1: boolean = true;
console.log(bool1);

let str4: string, num4: number, bool4: boolean;
str4 = '123';
num4 = 456;
bool4 = false;
console.log(str4, num4, bool4);

let bool3 = false;
bool3 = true;
console.log(bool3);


let aa: 'zheshu';
aa = 'zheshu';
console.log(aa);

let bb: 'zheshu' | 'yangyang' | 'sizhe' | 123 | false;
bb = 123;
console.log(bb);

let cc: any;
cc = 123;
let dd: any;
dd = cc;

console.log(cc);
console.log(dd);

let ee: unknown;
ee = 789;
ee = false;
let ff: string;
let gg: unknown;
gg = ee;
console.log(ee);

function sum(a: number, b: number): number {
    return a + b;
}

function foo(a: number, b: string): string {
    return a + b;
}
console.log(foo(4536, 'bb'));


function fun1(a: string, b: number): void {
    let c: string = a + b;
    console.log(c);
}
console.log(fun1('aa', 2));

let obj: { name:string, age: number };
obj = {
    name:'tom',
    age:18,
}
console.log(obj);

let obj2: { name:string, age:number, sex?:string}
obj2 = {
    name: 'lili',
    age:18,
}
console.log(obj2);

let obj3: { name: string, age: number, [propName: string]: unknown };
obj3 = {
    name: 'jenny',
    age: 16,
    sex: '女',
    height: 180
}
obj3.weight = 90;
console.log(obj3);

let arr: string[];
arr = ['st', 'greg', 'gerg'];

let arr1: number[];
arr1 = [1, 5, 9]

let arr3: Array<number>;
arr3 = [1, 5, 9];
let arr4: Array<string>;
arr4 = ['few', 'fef', 'geg'];

let arr5: [string, number, boolean];
arr5 = ['456',52,false];
console.log(arr5);

enum Color {
    Yellow,
    Pink,
    Blue
}
let monkey: Color = Color.Pink;
console.log(monkey, Color.Yellow, Color.Blue);
console.log(Color[0], Color[1], Color[2]);

let uu: 'zheshu' | 'yangyang' | 'sizhe' | 123;
uu = "zheshu";
uu = 123;
function boo(a: string | number, b: number): void {

    console.log(a, b);
}
boo(85, 45);

enum ObjTest {
    Zheshu, 
    YangYang,
    Sizhe
}
console.log(ObjTest['Zheshu']);
console.log(ObjTest[0]);

enum ObjTest1 {
    Zheshu = 6,
    YangYang,
    Sizhe
}
console.log(ObjTest1['Zheshu']);

function bunnn(x: number | string | false) {
    if ((<string>x).length) {
        console.log(111);
        return (<string>x).length;
    } else {
        console.log(222);
        return x.toString().length;
    }
}
console.log(bunnn(false));

function bunnn1(x: number | string | false) {
    if ((x as string).length) {
        console.log(111);
        return (<string>x).length;
    } else {
        console.log(222);
        return x.toString().length;
    }
}

console.log(bunnn1(false));

let apple = 'pingguo';
let appleA;
appleA = 13;
appleA = 'gerg';